<!DOCTYPE html>
<html lang="en"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>logo</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="icon" href="../../../static/images/favicon.ico" th:href="@{/images/favicon.ico}">
    <link rel="stylesheet" href="../../../static/plugin/layui/css/layui.css" th:href="@{/plugin/layui/css/layui.css}" media="all"/>
    <link rel="stylesheet" href="../../../static/back_css/create_works.css" th:href="@{/back_css/create_works.css}" media="all">
</head>
<body>
<div id="create_works_main">
    <div class="create_works_content">
        <div class="layui-form-item">
            <div class="layui-input-block">
                <span style="color: red;padding-left: 40%;">设置完成后请刷新！</span>
            </div>
        </div>
          <form class="layui-form">
          <div class="layui-form-item">
              <label class="layui-form-label"><span>LOGO</span></label><br>

              <div class="layui-input-block">
                  <input type="hidden" name="LOGO_IMG" id="LOGO_IMG">
                  <input type="file" autocomplete="off" name="file1" class="layui-input upload_file upload_file1" accept="image/*" id="LOGO_IMGtest">
                  <div class="upload_img layui-upload-list">
                      <img  class="layui-upload-img1" id="LogoImg1">
                      <span>请上传PNG、JPG、GIF格式图片</span>
                  </div>
                  <span style="color: red;">系统左上角LOGO</span>
                  <button lay-submit class="layui-btn btn_right" lay-filter="LOGO_IMG" style="    margin-left: 523px;">确定</button>
              </div>
          </div>
          </form>
          <form class="layui-form">
          <div class="layui-form-item">
              <label class="layui-form-label">系统头像</label><br>
              <div class="layui-input-block">
                  <input type="hidden" name="FANCE_IMG" id="FANCE_IMG">
                  <input type="file" autocomplete="off" name="file1" class="layui-input upload_file upload_file2" accept="image/*" id="FANCE_IMGtest">
                  <div class="upload_img layui-upload-list">
                      <img  class="layui-upload-img2" id="FanceImg1">
                      <span>请上传PNG、JPG、GIF格式图片</span>
                  </div>
                  <span style="color: red;">系统右上角头像（当管理员没有头像时使用此头像）</span>
                  <button lay-submit class="layui-btn btn_right" lay-filter="FANCE_IMG" style="    margin-left: 198px;">确定</button>
              </div>
          </div>
          </form>
          <form class="layui-form">
          <div class="layui-form-item">
              <label class="layui-form-label">二维码</label><br>
              <div class="layui-input-block">
                  <input type="hidden" name="WX_IMG" id="WX_IMG">
                  <input type="file" autocomplete="off" name="file1" class="layui-input upload_file upload_file3" accept="image/*" id="WX_IMGtest">
                  <div class="upload_img layui-upload-list">
                      <img  class="layui-upload-img3" id="WxImg1">
                      <span>请上传PNG、JPG、GIF格式图片</span>
                  </div>
                  <span style="color: red;">微信端操作指南中第一步的公众号二维码</span>
              </div>
          </div>
          <div class="layui-form-item ">
              <label class="layui-form-label">公众号名称</label>
              <div class="layui-input-block">
                  <input type="text" name="WX_COUNT" lay-verify="required"  autocomplete="off" th:value="${logo.getWX_COUNT()}" placeholder="请输入公众号名称" maxlength="200" class="layui-input">
              </div>
              <span style="color: red;">微信端操作指南中第一步关注对象（例：非悦book公众号）</span>
              <button lay-submit class="layui-btn btn_right" lay-filter="WX" style="    margin-left: 151px;">确定</button>
          </div>
          </form>
          <form class="layui-form">
          <div class="layui-form-item">
              <label class="layui-form-label">管理员头像</label><br>
              <div class="layui-input-block">
                  <input type="hidden" name="FACE_IMG" id="FACE_IMG">
                  <input type="file" autocomplete="off" name="file1" class="layui-input upload_file upload_file4" accept="image/*" id="FACE_IMGtest">
                  <div class="upload_img layui-upload-list">
                      <img  class="layui-upload-img4" id="FaceImg1">
                      <span>请上传PNG、JPG、GIF格式图片</span>
                  </div>
                  <span style="color: red;">系统右上角头像（当管理员没有头像时使用系统头像）</span>
                  <button lay-submit class="layui-btn btn_right" lay-filter="Face" style="    margin-left: 184px;">确定</button>
              </div>
          </div>
          </form>

        <input type="hidden" id="logoimg" th:value="${logo.getLOGO_IMG()}"/>
        <input type="hidden" id="fanceimg" th:value="${logo.getFANCE_IMG()}"/>
        <input type="hidden" id="wximg" th:value="${logo.getWX_IMG()}"/>
        <input type="hidden" id="faceimg" th:value="${logo.getFACE_IMG()}"/>
        <input type="hidden" id="level" th:value="${falg}"/>
    </div>
</div>

<script type="text/javascript" src="../../../static/plugin/layui/layui.js" th:src="@{/plugin/layui/layui.js}"></script>
<script>
    layui.use(['form', 'layedit', 'laydate','upload'], function() {
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate
            ,upload = layui.upload
            ,$ = layui.jquery;

        $(document).ready(function () {
            var logoimg = $("#logoimg").val();
            if(""!=logoimg){
                $('#LogoImg1').attr('src', logoimg);
                $(".upload_file1>span").css("display","none");
                $(".layui-upload-img1").css("display","block");
            }
            var fanceimg = $("#fanceimg").val();
            if(""!=fanceimg){
                $('#FanceImg1').attr('src', fanceimg);
                $(".upload_file2>span").css("display","none");
                $(".layui-upload-img2").css("display","block");
            }
            var wximg = $("#wximg").val();
            if(""!=wximg){
                $('#WxImg1').attr('src', wximg);
                $(".upload_file3>span").css("display","none");
                $(".layui-upload-img3").css("display","block");
            }
            var faceimg = $("#faceimg").val();
            if(""!=faceimg){
                $('#FaceImg1').attr('src', faceimg);
                $(".upload_file4>span").css("display","none");
                $(".layui-upload-img4").css("display","block");
            }
        });
        var audioIndex;
        var uploadInst = upload.render({
            elem: '#LOGO_IMGtest'
            , url: '/LogoUpload'
            , method:'post'
            , multiple: true
            ,before: function(obj){
                audioIndex=layer.load(1);
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                    $('#LogoImg1').attr('src', result); //图片链接（base64）
                });
                $(".upload_file1>span").css("display","none");
                $(".layui-upload-img1").css("display","block");
            }
            ,done: function(res){
                //如果上传失败
                if(res.code == 0){
                    return layer.msg('上传失败');
                }else {
                    layer.close(audioIndex);
                    $("#LOGO_IMG").val(res.pic);
                }
            }
        });
        var audioIndex1;
        var uploadInst = upload.render({
            elem: '#FANCE_IMGtest'
            , url: '/LogoUpload'
            , method:'post'
            , multiple: true
            ,before: function(obj){
                audioIndex1=layer.load(1);
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                    $('#FanceImg1').attr('src', result); //图片链接（base64）
                });
                $(".upload_file2>span").css("display","none");
                $(".layui-upload-img2").css("display","block");
            }
            ,done: function(res){
                //如果上传失败
                if(res.code == 0){
                    return layer.msg('上传失败');
                }else {
                    layer.close(audioIndex1);
                    $("#FANCE_IMG").val(res.pic);
                }
            }
        });
        var audioIndex2;
        var uploadInst = upload.render({
            elem: '#WX_IMGtest'
            , url: '/LogoUpload'
            , method:'post'
            , multiple: true
            ,before: function(obj){
                audioIndex2=layer.load(1);
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                    $('#WxImg1').attr('src', result); //图片链接（base64）
                });
                $(".upload_file3>span").css("display","none");
                $(".layui-upload-img3").css("display","block");
            }
            ,done: function(res){
                //如果上传失败
                if(res.code == 0){
                    return layer.msg('上传失败');
                }else {
                    layer.close(audioIndex2);
                    $("#WX_IMG").val(res.pic);
                }
            }
        });
        var audioIndex3;
        var uploadInst = upload.render({
            elem: '#FACE_IMGtest'
            , url: '/LogoUpload'
            , method:'post'
            , multiple: true
            ,before: function(obj){
                audioIndex3=layer.load(1);
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                    $('#FaceImg1').attr('src', result); //图片链接（base64）
                });
                $(".upload_file4>span").css("display","none");
                $(".layui-upload-img4").css("display","block");
            }
            ,done: function(res){
                //如果上传失败
                if(res.code == 0){
                    return layer.msg('上传失败');
                }else {
                    layer.close(audioIndex3);
                    $("#FACE_IMG").val(res.pic);
                }
            }
        });
        //设置logo
        form.on('submit(LOGO_IMG)', function (data) {
            var level = $("#level").val();
            if(level=="false"){
                layer.msg('您暂无权限修改！', {
                    icon: 2,
                    time: 2000
                });
            }else {
                $.ajax({//进行审核提交
                    url: '/upLogo',
                    async: false,
                    type: "POST",
                    data: {LOGO_IMG: data.field.LOGO_IMG},
                    success: function (data) {
                        // console.log(data)
                        if (data) {
                            layer.msg("提交成功！")
                        }
                    }
                })
            }
            return false;
        });
        //设置系统头像
        form.on('submit(FANCE_IMG)', function (data) {
            var level = $("#level").val();
            if(level=="false"){
                layer.msg('您暂无权限修改！', {
                    icon: 2,
                    time: 2000
                });
            }else {
                $.ajax({//进行审核提交
                    url: '/upFance',
                    async: false,
                    type: "POST",
                    data: {FANCE_IMG: data.field.FANCE_IMG},
                    success: function (data) {
                        // console.log(data)
                        if (data) {
                            layer.msg("提交成功！")
                        }
                    }
                })
            }
            return false;
        });
        //设置微信端
        form.on('submit(WX)', function (data) {
            var level = $("#level").val();
            if(level=="false"){
                layer.msg('您暂无权限修改！', {
                    icon: 2,
                    time: 2000
                });
            }else {
                $.ajax({//进行审核提交
                    url: '/upWx',
                    async: false,
                    type: "POST",
                    data: data.field,
                    success: function (data) {
                        // console.log(data)
                        if (data) {
                            layer.msg("提交成功！")
                        }
                    }
                })
            }
            return false;
        });
        //设置管理员头像
        form.on('submit(Face)', function (data) {
            $.ajax({//进行审核提交
                url: '/upFace',
                async: false,
                type: "POST",
                data: data.field,
                success: function (data) {
                    // console.log(data)
                    if (data) {
                        layer.msg("提交成功！")
                    }
                }
            })
            return false;
        });
    })
</script>
</body>
</html>